const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  var start=event.start
  var sortId = event.sortId
  // if (sortId =="f3db088f5e80c80d0028ee3c4415bdfa"){
  //   sortId ="42d70ff05e8d8d8e005cb4524c50a10b"
  // }
  const picsResult = await db.collection("pic").orderBy('ctime', 'asc').where({
    sortId:sortId
  }).limit(10).skip(start*10).get()
  if (picsResult.errMsg =="collection.get:ok"){
      return{
        code:0,
        data: picsResult.data
      }
  }else{
    return {
      code: 1,
      data: picsResult.errMsg
    }
  }
}